package org.hbs.blog.code.dao.impl;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.hbs.blog.code.dao.ICommentDao;
import org.hbs.blog.code.entity.Comment;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

@Repository("commentDao")
public class CommentDao extends SqlSessionDaoSupport implements ICommentDao {
	
	@Resource(name="sqlSessionFactory")
	private SqlSessionFactory sqlSessionFactory;
	
	@PostConstruct
	public void initializeSqlSessionFactory(){
		super.setSqlSessionFactory(sqlSessionFactory);
	}
	/*
	 * (non-Javadoc)
	 * @see org.hbs.blog.code.dao.ICommentDao#insertComment(org.hbs.blog.code.entity.Comment)
	 */
	public Comment insertComment(Comment comment) {
		super.getSqlSession().insert("insertComment", comment);
		return comment;
	}
	/*
	 * (non-Javadoc)
	 * @see org.hbs.blog.code.dao.ICommentDao#deleteCommentByID(java.lang.String)
	 */
	public void deleteCommentByID(String commentID) {
		super.getSqlSession().delete("deleteCommentByID", commentID);
	}
}
